<template>
	<view class="shop">
		<!-- 购物车页面布局开始 -->
		<block v-for="(item,index) in arr " :key="index">
			<view class="shop_list">
				<label>
					<checkbox :checked="item.check"  @click="aa(index)"/>
				</label>
				<image :src="'http://jd.itying.com/'+item.pic" mode="widthFix" lazy-load></image>
				<view class="shop_list_one">
					<view class="shop_list_two">
						<view class="">{{item.title}}</view>
						<view class="shop_list_three">
							<view class="" hover-class="a" @click="jia(index)">+</view>
							<view class="">{{item.num}}</view>
							<view class="" hover-class="a" @click="jian(index)"
							>-</view>
						</view>
					</view>
					<view class="shop_list_right">
						<view class="">{{item.price}}</view>
						<view class="iconfont icon-shanchu" @click="del(index)"></view>
					</view>
				</view>
			</view>
		</block>
		<!-- 底部定位 -->
		<view class="shop_fiex" v-if="isTrue">
			<label>
				<checkbox :checked="checkAll" @click="box()"/><text>全选</text>
			</label>
			<view class="">合计：{{sun}}</view>
			<view class="">结算</view>
		</view>
		
		<!-- 购物车页面布局结束 -->
	</view>
</template>

<script>
	import {mapState,mapGetters} from 'vuex';
	export default {
		name:'aa',
		data() {
			return {
				
			}
		},
		methods: {
			box(){
				this.$store.commit('box');
			},
			aa(k){
				this.$store.commit('aa',k);
				console.log(this.checkAll);
			},
			del(k){//删除
				this.$store.commit('del',k);
			},
			jia(k){//加
				this.$store.commit('jia',k);
			},
			jian(k){//减
				this.$store.commit('jian',k);
			}
		},
		computed:{
			...mapState(['arr','disable','checkAll']),
			...mapGetters(['sun'])
		}
	}
</script>

<style lang="scss">
	// 底部定位
	.shop_fiex{
		position: fixed;
		bottom: 0;
		left: 0;
		width: 95%;
		height: 100upx;
		display: flex;
		justify-content: space-between;
		padding: 20upx;
		border-top: 1px solid #C0C0C0;
		line-height: 100upx;
	}
	// 数据列表布局
	.shop_list{
		padding: 20upx 20upx;
		border-bottom: 1upx solid #C0C0C0;
		display: flex;
		justify-content: space-around;
		align-items: center;
		image{
			width: 140upx;
			height: 140upx;
		}
		.shop_list_one{
			padding-left: 20upx;
			flex: 1;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.shop_list_three{
				display: flex;
				align-items: center;
				view{
					width: 60upx;
					height: 50upx;
					border: 1upx solid #C0C0C0;
					text-align: center;
					
				}
				&>view:nth-child(2){
					border-left:none ;
					border-right: none;
				}
				.a{
					background-color: #C8C7CC;
				}
			}
		}
	}
	
	// 全局布局
	.shop{
		width: 100%;
		height: 100%;
	}
</style>
